#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int largestAltitude(vector<int>& gain) {
        int max = 0;
        int x = 0;
        for (auto& e : gain)
        {
            x += e;
            if (x > max)
                max = x;
        }
        return max;
    }
};